#!/bin/sh
# postinst script for netopeer2
#
# see: dh_installdeb(1)

set -e

# summary of how this script can be called:
#        * <postinst> `configure' <most-recently-configured-version>
#        * <old-postinst> `abort-upgrade' <new version>
#        * <conflictor's-postinst> `abort-remove' `in-favour' <package>
#          <new-version>
#        * <postinst> `abort-remove'
#        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
#          <failed-install-package> <version> `removing'
#          <conflicting-package> <version>
# for details, see https://www.debian.org/doc/debian-policy/ or
# the debian-policy package


case "$1" in
    configure)
	if ! getent group netconf > /dev/null; then
	    addgroup --quiet --system netconf
	fi
	env - \
	    SYSREPOCTL_EXECUTABLE=sysrepoctl \
	    NP2_MODULE_DIR=/usr/share/yang/modules/netopeer2 \
	    NP2_MODULE_PERMS=660 \
	    NP2_MODULE_OWNER=root \
	    NP2_MODULE_GROUP=netconf \
	    bash /usr/share/netopeer2/setup.sh
	env - \
	    SYSREPOCFG_EXECUTABLE=sysrepocfg \
	    OPENSSL_EXECUTABLE=openssl \
	bash /usr/share/netopeer2/merge_hostkey.sh
	env - \
	    SYSREPOCFG_EXECUTABLE=sysrepocfg \
	bash /usr/share/netopeer2/merge_config.sh
    ;;

    abort-upgrade|abort-remove|abort-deconfigure)
    ;;

    *)
        echo "postinst called with unknown argument \`$1'" >&2
        exit 1
    ;;
esac

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#

exit 0
